package gailv.mengtelaluo;

import java.util.Random;

public class MonteCarloGamblingSimulation {

    private static final int WIN = 1; // 庄家赢
    private static final int PLAYER_WIN = 2; // 玩家赢
    private static final int NUM_PEOPLE = 10; // 人数
    private static final int START_MONEY = 10; // 起始资金
    private static final int NUM_GAMES = 1000; // 赌博局数
    private static final int BET_AMOUNT = 1; // 每局赌注

    public static void main(String[] args) {
        // 模拟每个人赌博的结果
        for (int i = 0; i < NUM_PEOPLE; i++) {
            simulateGambling(START_MONEY);
        }
    }

    private static void simulateGambling(int initialMoney) {
        Random random = new Random();
        int money = initialMoney;

        for (int game = 0; game < NUM_GAMES && money > 0; game++) {
            int result = random.nextInt(2) + 1; // 随机生成1或2

            if (result == WIN) {
                money--; // 庄家赢，玩家减1元
            } else {
                money++; // 玩家赢，加1元
            }

            // 打印每次赌博的结果
            System.out.println("Game " + (game + 1) + ", Money: " + money);
            if (money == 0) {
                System.out.println("玩家输光了所有的钱，出局！");
                break;
            }
        }
    }
}
